Simple Lua (Old)
This is the old version follow the link to go to the new version. SIMPLE LUA Slightly revised version __TOC__ *Waiting *Redstone **Inputs **Outputs *Values *Functions And Arguments *loops Waiting Well you've created an Infinite Loop, but when you ran it your program your Minecraft crashed? Well what do you do.... You add a sleep( double Value ) Well you will learn what a double Value is later but a simple Explanation is: A number with a decimal. Redstone Well now you have a wait and a loop(I will teach you how to do a loop in loops) Now you want to edit redstone signals: the back is the side behind the monitor left is the left of the moniter top is the top of the monitor etc... well theres 2 ways to call the redstone funtion #rs() #redstone() Inputs: inputs are for when you want to do something when a redstone signal is read so its redstone.getInput( side ) Outputs: outputs are for when you want to set a redstone signal so its redstone.setOutput( side, boolean ) If you want to get all the sides and test which is true you use : redstone.getSides() And for extra help type *help programming *help api * help redstone Values: There are mas #Integers #Booleans #Tables #Doubles #Objects #nil #string Now lets go into detail: to define a value you need a name and a value like this = for a table you do = {,...etc} without the <> Functions And Arguments : A function is code put in a special carrier to get differant values or call it over and over again : functions are called like function(args) Simular isn't it ? Yes, redstone.*() is a function : APIS are made out of many functions and values to work togeather : to make a function you need : function () : -- code here : end Logic and loops logic is what makes computers work Ever heard of IF gates? If not its simple if value1 value2 then--if value1 equals value2 then --code here end the logic operators are put in the middle theres greater than > less than < greater or equal to >= less or equal to <= not ~= you can compare values and the same if statement like and, or, not this goes like this if v1 v2 and v3~=v4 then end if you want to do something if the condition is met and something else if its not then you add an else if v1 v2 then --code else --code end but what if you want 3 or more possibilitys? then theres elseif if v1 v2 then --code elseif v1>v2 then --code else --code end So when are we learning about Loops? Well there are 2 mainly used loops while loops and for loops a while loop is a special kind of loop that repeats until its condition is met so if you want an infanite loop : while true do : sleep(1) : end but if you want a loop that stops : con = 5 : met = 0 : while met < con do : met = met+ 1 : sleep(1) : print met : end If you want to read a players action like for a password you type write "Enter Password: "-- this displays Enter Password: (and reads only past here) a = read()-- allows an Input into the variable name a Which is a string Well that covers it.... Sorry if it's messy : without the <> Category:BAD Category:OLD Category:Lua Category:VAT21s Category:Out-Dated